<?php
/*
 * @Descripttion: 
 * @version: 1.0
 * @Author: Sam
 * @Date: 2021-07-27 14:55:18
 * @LastEditors: Sam
 * @LastEditTime: 2022-02-25 14:51:28
 */

namespace app\admin\model;
use think\Model;


/**
 * 提现申请
 * Class MerchantWithdrawApply
 * @package app\admin\model\MerchantWithdrawApply
 */
class MerchantWithdrawApply extends BaseModel
{

    /**
     * 数据表主键
     * @var string
     */
    protected $pk = 'id';

    /**
     * 模型名称
     * @var string
     */
    protected $name = 'merchant_withdraw_apply';
    // 开启自动写入时间戳字段
    protected $autoWriteTimestamp = true;


  

    public function merchant(){
        return $this->belongsTo(UserMerchant::class,'merchant_id');
    }

    public function getStatusTextAttr($value,$data){
        $status  = [0=>"待审核",1=>'审核通过',2=>'审核拒绝',3=>'已取消'];
        return $status[$data['status']];
    }


    public function getConfirmTimeAttr(){
        return $this->getData('confirm_time') ? date('Y-m-d H:i', $this->getData('confirm_time')) : '';
    }

    public function getBankNameAttr(){
        return Banks::where('bank_code',$this->getData('bank_code'))->value('bank_name') ?? '';
    }

}